export class EditorCtrl {
    public static parseHtml(code: string) {
        //得到需要执行的script代码
        let runScript = ""
        //正则匹配出script中的内容
        code = code.replace(/<script>([\s\S]+?)<\/script>/img, (_: any, js: any) => { runScript += js; return "" });
        //得到所有script 的外部链接地址
        let srcs: any = [];
        let html: any = code.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, (script: any, _: any) => {
            let src = script.match(/<script .*?src=\"(.+?)\"/);//拿到url
            if (src) {
                srcs.push(src[1]);
            }
            return "";
        }); //正则替换为空
        //得到html标签的内容
        html = html.match(/<html\b[^<]*(?:(?!<\/html>)<[^<]*)*<\/html>/gi);
        return { runScript, srcs, html };
    }
}